package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-08-23  12:24
 */
public class Computer {
    public void powerOn() {
        System.out.println("打开笔记本！");
    }

    public void poweroff() {
        System.out.println("关闭笔记本！");
    }

    public void useComputer(USB usb) {
        usb.openDevice();
        if(usb instanceof  Mouse) {
            Mouse mouse = (Mouse) usb;
            mouse.click();
        } else if (usb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard) usb;
            keyBoard.input();
        }
        usb.closeDevice();
    }
}
